﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;

namespace Articles
{
    public class DbHelp
    {
        private static readonly string ConString = "server=.;uid=sa;pwd=123456;database=CMS";

        public static DataTable GetTable (string sql)
        {
            SqlDataAdapter adapter = new SqlDataAdapter(sql, ConString);
            DataTable data = new DataTable();
            adapter.Fill(data);
            return data;
        }
        public static int  CRUD(string sql)
        {
            SqlConnection connection = new SqlConnection(ConString);
            SqlCommand command = new SqlCommand(sql, connection);
            connection.Open();
            var cm=command.ExecuteNonQuery();
            connection.Close();
            return cm;
        }
    }
}